package com.battle.service.repository.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.battle.pojo.entity.UserScreen;
import com.battle.service.mapper.UserScreenMapper;
import com.battle.service.repository.in.UserScreenRepository;
import nirvana.core.repository.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
    import com.battle.pojo.dto.userScreen.*;
    import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
* 【描 述】：
* 【环 境】：J2SE
* 【详 细】：
*
*/
@Service
public class UserScreenRepositoryImpl extends Repository< UserScreenMapper , UserScreen> implements UserScreenRepository {

private final UserScreenMapper mapper;

public UserScreenRepositoryImpl(UserScreenMapper mapper) {
this.mapper = mapper;
}

    /**
    * 搜索用户筛选框
    * @param dto
    * @return
    */
    @Override
    public Page< UserScreen > selectUserScreen(SelectUserScreenDto dto){

    return mapper.selectUserScreen(dto);
    }

@Override
public  Map<Long, UserScreen> getMap(List<Long> ids){
    Map<Long, UserScreen> map = new HashMap<>();

    if (CollectionUtil.isNotEmpty(ids)) {
        List<UserScreen> list =listByIds(ids);
        if (CollectionUtil.isNotEmpty(list)) {
        map = list.stream().collect(Collectors.toMap(UserScreen::getId, pojo -> pojo));
         }
        }
        return map;
    }
}